import { OperationDynamic } from './subComps/OperationDynamic'; // 生成需要
import type { EventInfo, ProTableInfo } from './utils/types';
// 初始化配置
export const initConfig = (onEvent: (eventInfo: EventInfo) => void): ProTableInfo => {
  return {
    openScroll: false,
    showExpandable: true,
    showFooter: true,
    showOptions: true,
    showPagination: true,
    showSearch: true,
    showToolBarRender: true,
    showToolbar: true,
    tableConfig: {
      rowKey: 'id',
      tableLayout: 'auto',
      bordered: true,
      size: 'small',
      showHeader: true,
      rowSelection: true,
      scroll: { x: 1200, y: 200 },
      columns: [
        { title: 'id', dataIndex: 'id', valueType: 'digit', value: 1, columnOrder: 1, order: 7 },
        { title: 'name', dataIndex: 'name', valueType: 'text', value: '赵先生1', columnOrder: 2, order: 6 },
        { title: 'age', dataIndex: 'age', valueType: 'digit', value: 19, columnOrder: 3, order: 5 },
        { title: 'phone', dataIndex: 'phone', valueType: 'digit', value: 18700871300, columnOrder: 4, order: 4 },
        { title: 'state', dataIndex: 'state', valueType: 'text', value: 'drop', columnOrder: 5, order: 3 },
        { title: 'createTime', dataIndex: 'createTime', valueType: 'digit', value: 1670678908770, columnOrder: 6, order: 2 },
        {
          title: '操作',
          dataIndex: 'table-operation',
          valueType: 'option',
          columnOrder: 7,
          render: (_: React.ReactNode, record: any, index: number) => {
            return OperationDynamic(['detail', 'edit', 'delete'], onEvent, { reactNode: _, record, index });
          },
        },
      ],
      headerTitle: '标题',
      tooltip: '标题 tooltip',
      footer: '表格Footer',
      options: { reload: true, search: true, density: true, fullScreen: true, setting: true },
      pagination: { position: 'bottomLeft', size: 'small', current: 1, pageSize: 20, showSizeChanger: true },
      search: { span: 8, collapseRender: true, labelWidth: 80, filterType: 'query', layout: 'horizontal' },
    },
    currentTableRecord: {},
    showModal: false,
    formType: 'detail',
    dataSource: {
      keyInfo: { key: 'id' },
      paginationInfo: { currentField: 'current', pageSizeField: 'pageSize' },
      apiList: {
        list: {
          url: '/api/selectList',
          method: 'Post',
          afterScript: 'dataList=response.data.list;total=response.data.total;',
          parameter: {},
          body: { current: 1, pageSize: 20, state: '' },
          data: [
            [
              { id: 1, name: '赵先生1', age: 19, phone: 18700871300, state: 'drop', createTime: 1670678908770 },
              { id: 2, name: '赵先生2', age: 19, phone: 18700871300, state: 'normal', createTime: 1670678908770 },
              { id: 3, name: '赵先生3', age: 19, phone: 18700871300, state: 'drop', createTime: 1670678908770 },
              { id: 4, name: '赵先生4', age: 19, phone: 18700871300, state: 'normal', createTime: 1670678908770 },
              { id: 5, name: '赵先生5', age: 19, phone: 18700871300, state: 'drop', createTime: 1670678908770 },
              { id: 6, name: '赵先生6', age: 19, phone: 18700871300, state: 'normal', createTime: 1670678908770 },
              { id: 7, name: '赵先生7', age: 19, phone: 18700871300, state: 'drop', createTime: 1670678908770 },
              { id: 8, name: '赵先生8', age: 19, phone: 18700871300, state: 'normal', createTime: 1670678908770 },
              { id: 9, name: '赵先生9', age: 19, phone: 18700871300, state: 'drop', createTime: 1670678908770 },
              { id: 10, name: '赵先生10', age: 19, phone: 18700871300, state: 'normal', createTime: 1670678908770 },
              { id: 11, name: '赵先生11', age: 19, phone: 18700871300, state: 'drop', createTime: 1670678908770 },
              { id: 12, name: '赵先生12', age: 19, phone: 18700871300, state: 'normal', createTime: 1670678908770 },
              { id: 13, name: '赵先生13', age: 19, phone: 18700871300, state: 'drop', createTime: 1670678908770 },
              { id: 14, name: '赵先生14', age: 19, phone: 18700871300, state: 'normal', createTime: 1670678908770 },
              { id: 15, name: '赵先生15', age: 19, phone: 18700871300, state: 'drop', createTime: 1670678908770 },
              { id: 16, name: '赵先生16', age: 19, phone: 18700871300, state: 'normal', createTime: 1670678908770 },
              { id: 17, name: '赵先生17', age: 19, phone: 18700871300, state: 'drop', createTime: 1670678908770 },
              { id: 18, name: '赵先生18', age: 19, phone: 18700871300, state: 'normal', createTime: 1670678908770 },
              { id: 19, name: '赵先生19', age: 19, phone: 18700871300, state: 'drop', createTime: 1670678908770 },
              { id: 20, name: '赵先生20', age: 19, phone: 18700871300, state: 'normal', createTime: 1670678908770 },
            ],
            999,
          ],
        },
        detail: { url: '/api/selectDetail', method: 'Get', afterScript: 'returnData=response.data', parameter: {}, body: {}, data: {} },
        add: { url: '/api/add', method: 'Post', afterScript: 'returnData=response.data', parameter: {}, body: {}, data: {} },
        delete: { url: '/api/delete', method: 'Get', afterScript: 'returnData=response.data', parameter: {}, body: {}, data: {} },
        update: { url: '/api/update', method: 'Post', afterScript: 'returnData=response.data', parameter: {}, body: {}, data: {} },
        deleteBatch: { url: '', method: '', afterScript: '', parameter: {}, body: {}, data: {} },
      },
    },
  };
};
